<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/css/oksub.css">
    <script type="text/javascript" src="/static/lib/loading/okLoading.js"></script>
    <script src="/static/lib/layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="{:addons_url('store://Brand/upcAdd')}" method="post" style="padding: 20px">
    {if !empty($data) }
    <input type="hidden" value="{$Request.param.id}" name="id">
    {else /}
    {/if}
    <div class="layui-form-item">
        <label class="layui-form-label">品牌名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" required lay-verify="required|name" placeholder="请输入品牌名称" value="{$data.name|default=''}"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">官网地址</label>
        <div class="layui-input-block">
            <input type="text" name="website_url" required lay-verify="required|website_url" placeholder="请输入官网地址"  value="{$data.website_url|default=''}"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    {include file="common/upload_icon" field="$data"/}
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" placeholder="排序"  lay-verify="sort" autocomplete="off" class="layui-input" value="{$data.sort|default='0'}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否启用</label>
        <div class="layui-input-block">
            {if !empty($data['is_enable']) && $data['is_enable'] == '否'}
            <input type="radio" name="is_enable" value="0" title="否" checked>
            <input type="radio" name="is_enable" value="1" title="是">
            {else /}
            <input type="radio" name="is_enable" value="0" title="否">
            <input type="radio" name="is_enable" value="1" title="是" checked>
            {/if}

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">SEO标题</label>
        <div class="layui-input-block">
            <input type="text" name="seo_title" lay-verify="seo_title" placeholder="SEO标题" autocomplete="off" class="layui-input" value="{$data.seo_title|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">SEO关键词</label>
        <div class="layui-input-block">
            <input type="text" name="seo_keywords" lay-verify="seo_keywords"  placeholder="SEO关键词" autocomplete="off" class="layui-input" value="{$data.seo_keywords|default=''}">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">SEO描述</label>
        <div class="layui-input-block">
            <textarea name="seo_desc" placeholder="请输入SEO描述"  lay-verify="seo_desc" class="layui-textarea">{$data.seo_desc|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script>
    layui.use(['form',"okLayer","okUtils"], function() {
        var form = layui.form;
        let okLayer = layui.okLayer;
        let okUtils = layui.okUtils;
        okLoading.close();
        //监听提交
        form.on('submit(formDemo)', function(data){
            console.log('提交')

            okUtils.ajax("{:addons_url('store://Brand/upcAdd')}", "post", data.field, true).done(function (response) {
                if (response.status === 200) {
                    okLayer.greenTickMsg(response.msg, function () {
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.location.reload()
                    })
                }
            }).fail(function (error) {
                console.log(error)
            });
            return false;
        });
    })
</script>
</html>